/**
 * Created by Mars on 2016/12/14.
 */
import React, {Component} from 'react';
import {
    StyleSheet,
    Navigator,
    View,
    Text,
    TouchableOpacity,
    TextInput,
    BackAndroid,
    Platform
} from 'react-native';

import HeaderWithSubmit from '../component/HeaderWithSubmit'

export default class WriteResume extends Component {
    // 构造
      constructor(props) {
        super(props);
        // 初始状态
        this.resume="";
        this.state = {};
      }

    _backtoResume = () => {
        const {navigator} = this.props;
        if (navigator) {
            navigator.pop();
        }
    };

    componentWillMount() {
        if (Platform.OS === 'android') {
            BackAndroid.addEventListener('hardwareBackPress', this.onBackAndroid);
        }
    }

    componentWillUnmount() {
        if (Platform.OS === 'android') {
            BackAndroid.removeEventListener('hardwareBackPress', this.onBackAndroid);
        }
    }

    /* Android返回键执行的操作 被之前BackAndroid组件调用*/
    onBackAndroid = () => {
        const {navigator} = this.props;
        const routers = navigator.getCurrentRoutes();
        if (routers.length > 1) {
            navigator.pop();
            return true;
        }
        return false;
    };

    render() {
        return (
            <View style={styles.container}>
                <HeaderWithSubmit name="填写简历"
                                  function={this._backtoResume}
                                  submit_name="提交"/>

                <View style={styles.body}>
                    <View style={styles.above}>
                        <Text style={styles.above_text}>
                            填写你的简历
                        </Text>
                    </View>

                    <TextInput style={styles.below}
                               underlineColorAndroid="transparent"
                               multiline={true}
                               placeholder="简历添加后不可更改，请确认简历的准确性。">
                    </TextInput>

                    <View style={{flex:4}}>
                    </View>
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container:{
        flex:1,
    },
    body:{
        flex:10,
    },
    above:{
        flex:1,
        marginLeft:10,
        marginTop:20,
    },
    above_text:{
        fontSize:20,
    },
    below:{
        flex:5,
        textAlignVertical:"top",
        marginLeft:10,
        marginRight:10,
        borderWidth:1,
        borderColor:"#CACACA",
    }
});